home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / wings / w2_src / extend.c < prev    next >
C/C++ Source or Header  |  1994-11-16  |  15KB  |  586 lines

  1. #include <egb.h>
  2. #include <mos.h>
  3. #include <time.h>
  4. #include <stdio.h>
  5. #include <fmcfrb.h>
  6. #include <msdos.cf>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "define.h"
  10. #include "extend.h"
  11.  
  12. #define BS 8
  13. #define RET 0xd
  14. #define SORT_MAX 2048
  15. #define    BUTTON_COL_1 8
  16. #define    BUTTON_COL_2 15
  17. #define    IMAGE_NUMBER_MAX 11
  18.  
  19. static    char    *image_buff[IMAGE_NUMBER_MAX];
  20.  
  21. // マウスカーソル形状設定関数
  22. void    mouse_type( char *pat_work, int n  )
  23. {
  24.  
  25.     UCHAR    ptn, data[ ] = { 136, 248, 143, 255 };
  26.     int        i, j;
  27.  
  28.     MOS_typeRom( n, 0, 0, pat_work );
  29.     for( i=130;i<=258;i++ )
  30.         *( pat_work + i + 384 ) = *( pat_work + i );
  31.     for( i=127;i>=0;i-- ){
  32.         ptn = *( pat_work + i+2 );
  33.         for( j=0;j<4;j++ )
  34.             *( pat_work + 2+i*4+j ) = data[ (ptn>>((3-j)*2)) & 3 ];
  35.     }
  36.  
  37. }
  38. // 点描画関数
  39. void    pset( char *egbwork, int x1, int y1, int c )
  40. {
  41.  
  42.     struct {
  43.         short    n, m1, m2;
  44.     } mark = { 1, 0, 0 };
  45.  
  46.     mark.m1 = x1;
  47.     mark.m2 = y1;
  48.     EGB_color( egbwork, 0, c );
  49.     EGB_pset( egbwork, ( char *)&mark );
  50.  
  51. }
  52. // 直線描画関数
  53. void    line( char *egbwork, int x1, int y1, int x2, int y2, int c )
  54. {
  55.  
  56.     struct {
  57.         short    n, m1, m2, m3, m4;
  58.     } mark = { 2, 0, 0, 0, 0 };
  59.  
  60.     mark.m1 = x1;
  61.     mark.m2 = y1;
  62.     mark.m3 = x2;
  63.     mark.m4 = y2;
  64.     EGB_color( egbwork, 0, c );
  65.     EGB_connect( egbwork, ( char *)&mark );
  66.  
  67. }
  68. // 枠線描画関数
  69. void    frame( char *egbwork, int x1, int y1, int x2, int y2, int c )
  70. {
  71.  
  72.     struct {
  73.         short    m1, m2, m3, m4;
  74.     } mark;
  75.  
  76.     mark.m1 = x1;
  77.     mark.m2 = y1;
  78.     mark.m3 = x2;
  79.     mark.m4 = y2;
  80.     EGB_color( egbwork, 0, c );
  81.     EGB_paintMode( egbwork, 2 );
  82.     EGB_rectangle( egbwork, ( char *)&mark );
  83.  
  84. }
  85. // 矩形描画関数
  86. void    box( char *egbwork, int x1, int y1, int x2, int y2, int c )
  87. {
  88.  
  89.     struct {
  90.         short    x1, y1, x2, y2;
  91.     } mark;
  92.  
  93.     mark.x1 = x1;
  94.     mark.y1 = y1;
  95.     mark.x2 = x2;
  96.     mark.y2 = y2;
  97.     EGB_color( egbwork, 0, c );
  98.     EGB_color( egbwork, 2, c );
  99.     EGB_paintMode( egbwork, 0x22 );
  100.     EGB_rectangle( egbwork, ( char *)&mark );
  101.  
  102. }
  103. // ペイント関数
  104. void    paint( char *egbwork, int x, int y, int c )
  105. {
  106.  
  107.     struct {
  108.         short    x, y;
  109.     } mark;
  110.  
  111.     mark.x = x;
  112.     mark.y = y;
  113.     EGB_color( egbwork, 0, c );
  114.     EGB_color( egbwork, 2, c );
  115.     EGB_paintMode( egbwork, 0x22 );
  116.     EGB_closePaint( egbwork, ( char *)&mark );
  117.  
  118. }
  119. // ボタン表示関数
  120. void    button_off( char *egbwork, int    x1, int y1, int x2, int y2 )
  121. {
  122.  
  123.     struct {
  124.         short    n, x1, y1, x2, y2;
  125.     } line = { 2, 0, 0, 0, 0 };
  126.  
  127.     EGB_color( egbwork, 0, BUTTON_COL_2 );
  128.     line.x1 = x1  , line.y1 = y1;
  129.     line.x2 = x1  , line.y2 = y2;
  130.     EGB_connect( egbwork, (char *)&line );
  131.     line.x1 = x1+1, line.y1 = y1;
  132.     line.x2 = x1+1, line.y2 = y2-1;
  133.     EGB_connect( egbwork, (char *)&line );
  134.     line.x1 = x1  , line.y1 = y1;
  135.     line.x2 = x2  , line.y2 = y1;
  136.     EGB_connect( egbwork, (char *)&line );
  137.     line.x1 = x1  , line.y1 = y1+1;
  138.     line.x2 = x2-1, line.y2 = y1+1;
  139.     EGB_connect( egbwork, (char *)&line );
  140.     EGB_color( egbwork, 0, BUTTON_COL_1 );
  141.     line.x1 = x1+1, line.y1 = y2;
  142.     line.x2 = x2  , line.y2 = y2;
  143.     EGB_connect( egbwork, (char *)&line );
  144.     line.x1 = x1+2, line.y1 = y2-1;
  145.     line.x2 = x2  , line.y2 = y2-1;
  146.     EGB_connect( egbwork, (char *)&line );
  147.     line.x1 = x2-1, line.y1 = y1+2;
  148.     line.x2 = x2-1, line.y2 = y2;
  149.     EGB_connect( egbwork, (char *)&line );
  150.     line.x1 = x2  , line.y1 = y1+1;
  151.     line.x2 = x2  , line.y2 = y2;
  152.     EGB_connect( egbwork, (char *)&line );
  153.  
  154. }
  155. // ボタン表示関数
  156. void    button_on( char *egbwork, int x1, int y1, int x2, int y2 )
  157. {
  158.  
  159.     struct {
  160.         short    n, x1, y1, x2, y2;
  161.     } line = { 2, 0, 0, 0, 0 };
  162.  
  163.     EGB_color( egbwork, 0, BUTTON_COL_1 );
  164.     line.x1 = x1  , line.y1 = y1;
  165.     line.x2 = x1  , line.y2 = y2;
  166.     EGB_connect( egbwork, (char *)&line );
  167.     line.x1 = x1+1, line.y1 = y1;
  168.     line.x2 = x1+1, line.y2 = y2-1;
  169.     EGB_connect( egbwork, (char *)&line );
  170.     line.x1 = x1  , line.y1 = y1;
  171.     line.x2 = x2  , line.y2 = y1;
  172.     EGB_connect( egbwork, (char *)&line );
  173.     line.x1 = x1  , line.y1 = y1+1;
  174.     line.x2 = x2-1, line.y2 = y1+1;
  175.     EGB_connect( egbwork, (char *)&line );
  176.     EGB_color( egbwork, 0, BUTTON_COL_2 );
  177.     line.x1 = x1+1, line.y1 = y2;
  178.     line.x2 = x2  , line.y2 = y2;
  179.     EGB_connect( egbwork, (char *)&line );
  180.     line.x1 = x1+2, line.y1 = y2-1;
  181.     line.x2 = x2  , line.y2 = y2-1;
  182.     EGB_connect( egbwork, (char *)&line );
  183.     line.x1 = x2-1, line.y1 = y1+2;
  184.     line.x2 = x2-1, line.y2 = y2;
  185.     EGB_connect( egbwork, (char *)&line );
  186.     line.x1 = x2  , line.y1 = y1+1;
  187.     line.x2 = x2  , line.y2 = y2;
  188.     EGB_connect( egbwork, (char *)&line );
  189.  
  190. }
  191. // 時間待ち関数
  192. void    sleep( int n )
  193. {
  194.  
  195.     clock_t    start;
  196.  
  197.     start = clock( );
  198.     while(  clock( ) - start<=n );
  199.  
  200. }
  201. int        font_start( char *str_ptn, char *path )
  202. {
  203.  
  204.     FILE    *fp;
  205.     
  206.     if( ( fp = fopen( path, "rb" ) )==NULL )
  207.         return( -1 );
  208.     fread( str_ptn, 1, 110592, fp );
  209.     fclose( fp );
  210.     return( 0 );
  211.  
  212. }
  213. // イメージ格納関数
  214. int        getimage( char *egbwork, int x1, int y1, int x2, int y2, int n )
  215. {
  216.  
  217.     int        page_0, page_1, d_mode;
  218.     USHORT    egb_sel;
  219.     struct {
  220.         char    *ptn;
  221.         short    ds, x1, y1, x2, y2;
  222.     } image = { NULL, 0x14, 0, 0, 0, 0 };
  223.  
  224.     n %= IMAGE_NUMBER_MAX; // 10番は通常ファイルセレクタが使う
  225.     egb_sel = getds( );
  226.     EGB_getResolution( &page_0, &page_1 );
  227.     d_mode = EGB_getWritePage( egbwork, egb_sel );
  228.  
  229.     if( !d_mode ){
  230.         if( page_0<=4 )
  231.             image_buff[ n ] = malloc( ( x2-x1+8 ) / 8 * 4 * ( y2-y1+1 ) );
  232.         else if( page_0>=5 && page_0<=11 )
  233.             image_buff[ n ] = malloc( ( x2 - x1 + 1 ) * ( y2 - y1 + 1 ) * 2 );
  234.         else if( page_0>=12 && page_0<=14 )
  235.             image_buff[ n ] = malloc( ( x2 - x1 + 1 ) * ( y2 - y1 + 1 ) );
  236.         else
  237.             image_buff[ n ] = malloc( ( x2 - x1 + 1 ) * ( y2 - y1 + 1 ) * 2 );
  238.     }
  239.     else {
  240.         if( page_1<=4 )
  241.             image_buff[ n ] = malloc( ( x2-x1+8 ) / 8 * 4 * ( y2-y1+1 ) );
  242.         else if( page_1>=5 && page_1<=11 )
  243.             image_buff[ n ] = malloc( ( x2 - x1 + 1 ) * ( y2 - y1 + 1 ) * 2 );
  244.         else if( page_1>=12 && page_1<=14 )
  245.             image_buff[ n ] = malloc( ( x2 - x1 + 1 ) * ( y2 - y1 + 1 ) );
  246.         else
  247.             image_buff[ n ] = malloc( ( x2 - x1 + 1 ) * ( y2 - y1 + 1 ) * 2 );
  248.     }
  249.     if( image_buff[ n ]==NULL )
  250.         return( -1 );
  251.     image.ptn = image_buff[ n ];
  252.     image.x1 = x1;
  253.     image.y1 = y1;
  254.     image.x2 = x2;
  255.     image.y2 = y2;
  256.     EGB_getBlock( egbwork, ( char *)&image );
  257.     return( 0 );
  258.     
  259. }
  260. // イメージ復帰関数
  261. void    putimage( char *egbwork, int x1, int y1, int x2, int y2, int n )
  262. {
  263.  
  264.     struct {
  265.         char    *ptn;
  266.         short    ds, x1, y1, x2, y2;
  267.     } image = { NULL, 0x14, 0, 0, 0, 0 };
  268.  
  269.     image.ptn = image_buff[ n % IMAGE_NUMBER_MAX ];
  270.     image.x1 = x1;
  271.     image.y1 = y1;
  272.     image.x2 = x2;
  273.     image.y2 = y2;
  274.     EGB_putBlock( egbwork, 0, ( char *)&image );
  275.     free( image_buff[ n ] );
  276.  
  277. }
  278. // パレット設定関数
  279. void    palette( char *egbwork, int c, int b, int r, int g )
  280. {
  281.  
  282.     struct {
  283.         int        num;
  284.         int        c_num;
  285.         char    b, r, g, zero;
  286.     } pal = { 1, 0, 0, 0, 0, 0 };
  287.     
  288.     pal.c_num = c;
  289.     pal.b = b;
  290.     pal.r = r;
  291.     pal.g = g;
  292.     EGB_palette( egbwork, 1, ( char *)&pal );
  293.     
  294. }
  295. // TMENUパレット設定関数
  296. void    tmenu_pal( char *egbwork )
  297. {
  298.  
  299.     palette( egbwork, 1,  8*16,  1*16, 11*16 );
  300.     palette( egbwork, 2, 12*16,  9*16, 13*16 );
  301.     palette( egbwork, 3, 15*16,  7*16,  6*16 );
  302.     palette( egbwork, 4, 12*16,  9*16, 10*16 );
  303.     
  304. }
  305. // 文字列ソート関数
  306. void    sort_string( char *str[ ], int n )
  307. {
  308.  
  309.     char    *buff_a;
  310.     int        i, j;
  311.  
  312.     for( j=0;j<=n-2;j++ ){
  313.         for( i=0;i<=n-2-j;i++ ){
  314.             if( strcmp( str[ i ], str[ i+1 ] )>=1 ){
  315.                 buff_a = str[ i+1 ];
  316.                 str[ i+1 ] = str[ i ];
  317.                 str[ i   ] = buff_a;
  318.             }
  319.         }
  320.     }
  321.  
  322. }
  323. // 数値列ソート関数(大きい順)
  324. void    sort_num_upper( int *num, int n )
  325. {
  326.  
  327.     int        i, j, dummy;
  328.  
  329.     for( j=0;j<=n-2;j++ ){
  330.         for( i=0;i<=n-2-j;i++ ){
  331.             if( *( num + i )<*( num + i+1 ) )
  332.                 swap( *( num + i ), *( num + i+1 ), dummy )
  333.         }
  334.     }
  335.  
  336. }
  337. // 数値列ソート関数(小さい順)
  338. void    sort_num_lower( int *num, int n )
  339. {
  340.  
  341.     int        i, j, dummy;
  342.  
  343.     for( j=0;j<=n-2;j++ ){
  344.         for( i=0;i<=n-2-j;i++ ){
  345.             if( *( num + i )>*( num + i+1 ) )
  346.                 swap( *( num + i ), *( num + i+1 ), dummy )
  347.         }
  348.     }
  349.  
  350. }
  351. // 逆写像ソート
  352. int        reverse_sort_lower( int *num, int n )
  353. {
  354.  
  355.     int        i, j, k, *p;
  356.     int        max_element = 16384 * 10; // 要素の最大値を決定する
  357.  
  358.     if( ( p = ( int *)calloc( max_element, 4 ) )==NULL )
  359.         return( -1 );
  360.     for( i=0;i<=n-1;i++ )
  361.         ( *( p + *( num + i ) ) )++;
  362.     k = 0;
  363.     for( i=0;i<=max_element-1;i++ ){
  364.         if( *( p + i ) ){
  365.             for( j=0;j<=*( p + i )-1;j++ )
  366.                 *( num + j+k ) = i;
  367.             k += j;
  368.         }
  369.     }
  370.     free( p );
  371.     return( 0 );
  372.  
  373. }
  374. int        reverse_sort_upper( int *num, int n )
  375. {
  376.  
  377.     int        i, j, k, *p;
  378.     int        max_element = 16384 * 10; // 要素の最大値を決定する
  379.  
  380.     if( ( p = ( int *)calloc( max_element, 4 ) )==NULL )
  381.         return( -1 );
  382.     for( i=0;i<=n-1;i++ )
  383.         ( *( p + *( num + i ) ) )++;
  384.     k = 0;
  385.     for( i=max_element-1;i>=0;i-- ){
  386.         if( *( p + i ) ){
  387.             for( j=0;j<=*( p + i )-1;j++ )
  388.                 *( num + j+k ) = i;
  389.             k += j;
  390.         }
  391.     }
  392.     free( p );
  393.     return( 0 );
  394.  
  395. }
  396. // キー入力関数
  397. int        key_read( int *key, int r )
  398. {
  399.  
  400.         char    matrix[ 16 ];
  401. static    char    map[ ] = {  /* Cap on and Shift Off */
  402.                              0,   0, '1', '2', '3', '4', '5', '6',
  403.                            '7', '8', '9', '0', '-', '^','\\',   8,
  404.                              0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
  405.                            'I', 'O', 'P', '@', '[',  13, 'A', 'S',
  406.                            'D', 'F', 'G', 'H', 'J', 'K', 'L', ';',
  407.                            ':', ']', 'Z', 'X', 'C', 'V', 'B', 'N',
  408.                            'M', ',', '.', '/', '"', ' ', '*', '/',
  409.                            '+', '-', '7', '8', '9', '=', '4', '5',
  410.                            '6',   0, '1', '2', '3',  13, '0', '.',
  411.                              0,   0,   0,   0,   0,  30,   0,  29,
  412.                             31,  28,   0, 128,   0, 129,   0,   0,
  413.                              0,   0, 130,   0,   0,   0,   0,   0,
  414.                             /* Cap On or Shift on */
  415.                              0,   0, '!', '"', '#', '$', '%', '&',
  416.                             39, '(', ')',   0, '=', '~', '|',   0,
  417.                              0, 'q', 'w', 'e', 'r', 't', 'y', 'u',
  418.                            'i', 'o', 'p', '`', '{',  13, 'a', 's',
  419.                            'd', 'f', 'g', 'h', 'j', 'k', 'l', '+',
  420.                            '*', '}', 'z', 'x', 'c', 'v', 'b', 'n',
  421.                            'm', '<', '>', '?', '_', ' ', '*', '/',
  422.                            '+', '-', '7', '8', '9', '=', '4', '5',
  423.                            '6',   0, '1', '2', '3',  13, '0', '.',
  424.                              0,   0,   0,   0,   0,  30,   0,  29,
  425.                             31,  28,   0, 128,   0, 129,   0,   0,
  426.                              0,   0, 130,   0,   0,   0,   0,   0,
  427.                             /* Cap Off or Shift Off */
  428.                              0,   0, '1', '2', '3', '4', '5', '6',
  429.                            '7', '8', '9', '0', '-', '^','\\',   8,
  430.                              0, 'q', 'w', 'e', 'r', 't', 'y', 'u',
  431.                            'i', 'o', 'p', '@', '[',  13, 'a', 's',
  432.                            'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
  433.                            ':', ']', 'z', 'x', 'c', 'v', 'b', 'n',
  434.                            'm', ',', '.', '/', '"', ' ', '*', '/',
  435.                            '+', '-', '7', '8', '9', '=', '4', '5',
  436.                            '6',   0, '1', '2', '3',  13, '0', '.',
  437.                              0,   0,   0,   0,   0,  30,   0,  29,
  438.                             31,  28,   0, 128,   0, 129,   0,   0,
  439.                              0,   0, 130,   0,   0,   0,   0,   0,
  440.                             /* Cap Off or Shift On */
  441.                              0,   0, '!', '"', '#', '$', '%', '&',
  442.                             39, '(', ')',   0, '=', '~', '|',   0,
  443.                              0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
  444.                            'I', 'O', 'P', '`', '{',  13, 'A', 'S',
  445.                            'D', 'F', 'G', 'H', 'J', 'K', 'L', '+',
  446.                            '*', '}', 'Z', 'X', 'C', 'V', 'B', 'N',
  447.                            'M', '<', '>', '?', '_', ' ', '*', '/',
  448.                            '+', '-', '7', '8', '9', '=', '4', '5',
  449.                            '6',   0, '1', '2', '3',  13, '0', '.',
  450.                              0,   0,   0,   0,   0,  30,   0,  29,
  451.                             31,  28,   0, 128,   0, 129,   0,   0,
  452.                              0,   0, 130,   0,   0,   0,   0,   0,
  453.                             /* Kana On */
  454.                              0,   0, 'ヌ', 'フ', 'ア', 'ウ', 'エ', 'オ',
  455.                            'ヤ', 'ユ', 'ヨ', 'ワ', 'ホ', 'ヘ', 'ー',   8,
  456.                              0, 'タ', 'テ', 'イ', 'ス', 'カ', 'ン', 'ナ',
  457.                            'ニ', 'ラ', 'セ', '゙', '゚',  13, 'チ', 'ト',
  458.                            'シ', 'ハ', 'キ', 'ク', 'マ', 'ノ', 'リ', 'レ',
  459.                            'ケ', 'ム', 'ツ', 'サ', 'ソ', 'ヒ', 'コ', 'ミ',
  460.                            'モ', 'ネ', 'ル', 'メ', 'ロ', ' ', '*', '/',
  461.                            '+', '-', '7', '8', '9', '=', '4', '5',
  462.                            '6',   0, '1', '2', '3',  13, '0', '.',
  463.                              0,   0,   0,   0,   0,  30,   0,  29,
  464.                              31,  28,   0, 128,   0, 129,   0,   0,
  465.                              0,   0, 130,   0,   0,   0,   0,   0,
  466.                             /* Kana On and Shift + */
  467.                              0,   0,   0,   0, 'ァ', 'ゥ', 'ェ', 'ォ',
  468.                            'ャ', 'ュ', 'ョ', 'ヲ',   0,   0,   0,   0,
  469.                              0,   0,   0,   0,   0,   0,   0,   0,
  470.                              0,   0,   0,   0,  '「',  13,  0,   0,
  471.                              0,   0,   0,   0,   0,   0,   0,   0,
  472.                              0, '」', 'ッ',   0,   0,   0,   0,   0,
  473.                              0, '、', '。', '・',   0, ' ', '*', '/',
  474.                            '+', '-', '7', '8', '9', '=', '4', '5',
  475.                            '6',   0, '1', '2', '3',  13, '0', '.',
  476.                              0,   0,   0,   0,   0,  30,   0,  29,
  477.                             31,  28,   0, 128,   0, 129,   0,   0,
  478.                              0,   0, 130,   0,   0,   0,   0,  0 };
  479.         int        i = 0, j = 0, flag = 0;
  480.         UINT    encode;
  481. static    int        key_mode[2];
  482.  
  483.     encode = KYB_shift( );
  484.     key_mode[ 0 ] = ( encode & 0x01 ) ? 1 : 0;
  485.     key_mode[ 1 ] = ( encode & 0x02 ) ? 1 : 0;
  486.     KYB_matrix( matrix );
  487.     KYB_clrbuf( );
  488.     *key = key_mode[ 0 ] + key_mode[ 1 ] * 2;
  489.     if( matrix[ 10 ] & 0x08 ){
  490.         KYB_clrbuf( );
  491.         KYB_matrix( matrix );
  492.         flag = 1;
  493.     }
  494.     if( matrix[ 10 ] & 0x20 ){
  495.         KYB_matrix( matrix );
  496.         while( matrix[ 10 ] & 0x20 )
  497.             KYB_matrix( matrix );
  498.         KYB_clrbuf( );
  499.         encode = KYB_shift( );
  500.         key_mode[ 0 ] = ( encode & 0x01 ) ? 1 : 0;
  501.         key_mode[ 1 ] = ( encode & 0x02 ) ? 1 : 0;
  502.         *key = key_mode[ 0 ] + key_mode[ 1 ] * 2;
  503.         return( 0 );
  504.     }
  505.     if( matrix[ 11 ] & 0x04 ){
  506.         KYB_matrix( matrix );
  507.         while( matrix[ 11 ] & 0x04 )
  508.             KYB_matrix( matrix );
  509.         KYB_clrbuf( );
  510.         encode = KYB_shift( );
  511.         key_mode[ 0 ] = ( encode & 0x01 ) ? 1 : 0;
  512.         key_mode[ 1 ] = ( encode & 0x02 ) ? 1 : 0;
  513.         *key = key_mode[ 0 ] + key_mode[ 1 ] * 2;
  514.         return( 0 );
  515.     }
  516.     while( i<=11 && !matrix[ i ] )
  517.         i++;
  518.     if( i>=12 )
  519.         return( 0 );
  520.     while( !( matrix[ i ] & 0x01 ) ){
  521.         matrix[ i ] >>= 1;
  522.         j++;
  523.     }
  524.     if( i==10 && j==3 )
  525.         return( 0 );
  526.     if( i+j ){
  527.         if( !r ){
  528.             KYB_matrix( matrix );
  529.             while( matrix[ i ] & ( 1 << j ) )
  530.                 KYB_matrix( matrix );
  531.         }
  532.         else
  533.             sleep( 2 );
  534.         KYB_clrbuf( );
  535.     }
  536.     else
  537.         return( 0 );
  538.     if( !flag && key_mode[ 0 ] && !key_mode[ 1 ] )
  539.         return( ( int )map[ i*8+j ] );
  540.     else if( flag && key_mode[ 0 ] && !key_mode[ 1 ] )
  541.         return( ( int )map[ 0x60+i*8+j ] );
  542.     else if( !flag && !key_mode[ 0 ] && !key_mode[ 1 ] )
  543.         return( ( int )map[ 0xc0+i*8+j ] );
  544.     else if( flag && !key_mode[ 0 ] && !key_mode[ 1 ] )
  545.         return( ( int )map[ 0x120+i*8+j ] );
  546.     else if( !flag && key_mode[ 1 ] )
  547.         return( ( int )map[ 0x180+i*8+j ] );
  548.     else
  549.         return( ( int )map[ 0x1e0+i*8+j ] );
  550.  
  551. }
  552. // ディスク状態収得関数
  553. void    disk_status( int n, int *not, int *pro )
  554. {
  555.  
  556.     UINT    s;
  557.     
  558.     DKB_setmode( 0x20+n, 0x0003, 0x0208 );
  559.     DKB_rdstatus( 0x20+n, &s );
  560.     *not = s & 0x01;
  561.     *pro = s & 0x02;
  562.  
  563. }
  564. // マウスループ
  565. void    mos_loop( int n  )
  566. {
  567.  
  568.     int        ch;
  569.     
  570.     do{
  571.         MOS_rdpos( &ch, 0, 0 );
  572.     }while( ch==n );
  573.     
  574. }
  575. // マウスループ
  576. void    mos_loop_not( int n  )
  577. {
  578.  
  579.     int        ch;
  580.     
  581.     do{
  582.         MOS_rdpos( &ch, 0, 0 );
  583.     }while( ch!=n );
  584.     
  585. }
  586.